home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 3: Developer Tools / Linux Cubed Series 3 - Developer Tools.iso / devel / lang / eiffel / smalleif.97 / se.t / SmallEiffel / lib_test / test_array2.e < prev    next >
Encoding:
Text File  |  1996-05-02  |  2.2 KB  |  116 lines

  1. -- Part of SmallEiffel -- Read DISCLAIMER file -- Copyright (C) 
  2. -- Dominique COLNET and Suzanne COLLIN -- colnet@loria.fr
  3. --
  4. class TEST_ARRAY2
  5.  
  6. creation {ANY}
  7.    make
  8.    
  9. feature {ANY}
  10.    
  11.    a, b: ARRAY2[INTEGER];
  12.    
  13.    make is
  14.       local
  15.      i1, i2, v: INTEGER;
  16.       do
  17.      !!a.make(1,2,3,4);
  18.      is_true(a.count = 4);
  19.      is_true(a.lower1 = 1);
  20.      is_true(a.upper1 = 2);
  21.      is_true(a.lower2 = 3);
  22.      is_true(a.upper2 = 4);
  23.      is_true(a.item(1,3) = 0);
  24.      
  25.      !!a.make(1,3,1,3);
  26.      is_true(a.count = 9);
  27.      is_true(a.lower1 = 1);
  28.      is_true(a.upper1 = 3);
  29.      is_true(a.lower1 = 1);
  30.      is_true(a.upper2 = 3);
  31.      !!b.array2(<<<<0,0,0>>,
  32.               <<0,0,0>>,
  33.               <<0,0,0>>>>);
  34.      is_true(b.count = 9);
  35.      is_true(b.lower1 = 1);
  36.      is_true(b.upper1 = 3);
  37.      is_true(b.lower1 = 1);
  38.      is_true(b.upper2 = 3);
  39.      
  40.      is_true(a.is_equal(b));
  41.      is_true(equal(a,b));
  42.       
  43.       
  44.      from  
  45.         !!a.array2(<<<<1,2,3>>,
  46.              <<4,5,6>>,
  47.              <<7,8,9>>>>);
  48.         i1 := a.lower1;
  49.         i2 := a.lower2;
  50.         v := 1;
  51.      until
  52.         v > 9
  53.      loop
  54.         is_true(v = a.item(i1,i2));
  55.         v := v + 1;
  56.         if i2 = a.upper2 then
  57.            i1 := i1 + 1;
  58.            i2 := a.lower2;
  59.         else
  60.            i2 := i2 + 1;
  61.         end;
  62.      end;
  63.       
  64.       
  65.            from  
  66.         b := clone(a);
  67.         i1 := a.lower1;
  68.         i2 := a.lower2;
  69.         v := 1;
  70.      until
  71.         v > 9
  72.      loop
  73.         is_true(v = a.item(i1,i2));
  74.         is_true(v = b.item(i1,i2));
  75.         v := v + 1;
  76.         if i2 = a.upper2 then
  77.            i1 := i1 + 1;
  78.            i2 := a.lower2;
  79.         else
  80.            i2 := i2 + 1;
  81.         end;
  82.      end;
  83.      
  84.      is_true(equal(a,b));
  85.      b.put(0,2,2);
  86.      is_true(not equal(a,b));
  87.       
  88.      
  89.      !!a.array2(<<<<1,2,2>>,
  90.               <<4,5,6>>,
  91.               <<7,8,9>>>>);
  92.      is_true(a.nb_occurrences(2) = 2);
  93.      is_true(a.nb_occurrences(3) = 0);
  94.      is_true(a.nb_occurrences(4) = 1);
  95.      
  96.      is_true(a.fast_nb_occurrences(2) = 2);
  97.      is_true(a.fast_nb_occurrences(3) = 0);
  98.      is_true(a.fast_nb_occurrences(4) = 1);
  99.       end;
  100.    
  101.    is_true(bool: BOOLEAN) is
  102.       do
  103.      cpt := cpt + 1;
  104.      if not bool then
  105.         std_output.put_string("TEST_ARRAY2: ERROR Test # ");
  106.         std_output.put_integer(cpt);
  107.         std_output.put_string("%N");
  108.      else
  109.         -- std_output.put_string("Yes%N");
  110.      end;
  111.       end;
  112.    
  113.    cpt: INTEGER;
  114.    
  115. end -- TEST_ARRAY2
  116.